import { defineStore } from 'pinia'
import { getData } from '../nextwork/request';
import type { RootObject, Child, ChinaAdd, ChinaTotal, StatisGradeCityDetail } from './type'
export const useMainStore = defineStore('Main', {
    state: () => {
        return {
            list: <RootObject>{},
            item: <Child[]>[],
            chinaAdd: <ChinaAdd>{},
            chinaTotal: <ChinaTotal>{},
            cityDetail: <StatisGradeCityDetail[]>[]
        }
    },
    actions: {
        async getList() {
            const result = await getData()
            this.list = result.data
            this.chinaAdd = this.list.diseaseh5Shelf.chinaAdd
            this.chinaTotal = this.list.diseaseh5Shelf.chinaTotal
            this.cityDetail = this.list.statisGradeCityDetail.slice(0,10)
        }
    }
})

